package com.iMusic.businessLogicLayer.testCase;

import java.sql.SQLException;
import java.util.Random;

import com.iMusic.businessLogicLayer.Staff;

import junit.framework.Assert;
import junit.framework.TestCase;

public class TestStaffCase extends TestCase{
	
	public void testCreateStaff(){
		
		Staff staff = new Staff();
		Random random=new Random();
		int i = random.nextInt(10000); 
		String s = String.valueOf(i);
		System.out.println(i);
		System.out.println(s);
		staff.setUsername("st"+s);
		staff.setPasswd("st");
		staff.setName("st");
		staff.setEmail("st@gmail.com");
		
		boolean test = false;
		try {
			test = staff.createStaff();
		} catch (SQLException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		Assert.assertEquals("Staff should be create!", true, test);
			
	}
	
	public void testLoginCase1(){
		
		Staff staff = new Staff();
		staff.setUsername("stst");
		staff.setPasswd("stst");
		staff.setName("stst");
		staff.setEmail("st@gmail.com");
		
		try {
			staff.createStaff();
		} catch (SQLException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		boolean test = false;
		try {
			test = staff.login();
			}
		catch (SQLException e) {
			e.printStackTrace();
		}
		Assert.assertEquals("Staff login should be success!", true, test);
		
	}
	
	public void testLoginCase2(){
		
		Staff staff = new Staff();
		staff.setUsername("stst");
		staff.setPasswd("stst11");
		boolean test = false;
		try {
			test = staff.login();
			}
		catch (SQLException e) {
			e.printStackTrace();
		}
		Assert.assertEquals("Staff login should not be success! -- The Wrong Password", false, test);
		//System.out.println("test="+test);
		
	}
	
	public void testLoginCase3(){
		
		Staff staff = new Staff();
		staff.setUsername("ststst");
		staff.setPasswd("stst11");
		boolean test = false;
		try {
			test = staff.login();
			}
		catch (SQLException e) {
			e.printStackTrace();
		}
		Assert.assertEquals("Staff login should not be success! -- The user is not Exist", false, test);
		//System.out.println("test="+test);
		
	}
	
	public void testLogoutCase(){
		
		Staff staff = new Staff();
		staff.setUsername("stst");
		staff.setPasswd("stst");
		boolean test = false;
		try {
			staff.login();
			test = staff.logout();
			}
		catch (SQLException e) {
			e.printStackTrace();
		}
		Assert.assertEquals("Staff login should be logout!", true, test);
		//System.out.println("test="+test);
		
	}
	
	

}
